﻿#ifndef SWANLINK_FINANCE_CARDSENDER_ADAPTOR_F5G006_LIB_LIBF5G006_INCLUDE_LOGUTILS_H
#define SWANLINK_FINANCE_CARDSENDER_ADAPTOR_F5G006_LIB_LIBF5G006_INCLUDE_LOGUTILS_H

#include "logger.h"
#include "string_utils.h"

#define log_debug(...) \
    do { if (globalLogger().isLoggable(LL_DEBUG)) { globalLogger().writeln(LL_DEBUG, __VA_ARGS__); }} while (0);
            


#define log_info(...) \
    do { if (globalLogger().isLoggable(LL_INFO)) \
            globalLogger().writeln(LL_INFO, __VA_ARGS__); } while(0);


#define log_error(...) \
    do { if (globalLogger().isLoggable(LL_ERROR)) \
            globalLogger().writeln(LL_ERROR, __VA_ARGS__); } while(0);


#define log_syserror(func_name, err_code) \
    do { if (globalLogger().isLoggable(LL_ERROR)) \
            globalLogger().writeln(LL_ERROR, "%s 失败: %d, %s", \
                func_name, err_code, formatSystemError(err_code)->c_str()); } while(0);


#define log_txdata(data, count) \
    do { if (globalLogger().isLoggable(LL_DEBUG)) \
            globalLogger().writeln(LL_DEBUG, "TX(%d): %s  %s", count, \
                bytesToHexString(data, count)->c_str(), \
                bytesToPrintableString(data, count)->c_str()); } while(0);


#define log_rxdata(data, count) \
    do { if (globalLogger().isLoggable(LL_DEBUG)) \
            globalLogger().writeln(LL_DEBUG, "RX(%d): %s  %s", count, \
                bytesToHexString(data, count)->c_str(), \
                bytesToPrintableString(data, count)->c_str()); } while(0);


#endif  // SWANLINK_FINANCE_CARDSENDER_ADAPTOR_F5G006_LIB_LIBF5G006_INCLUDE_LOGUTILS_H

